/*
package com.lzy.token.factory.impl;


import com.lzy.util.TokenUtil;
import com.lzy.model.AuthToken;
import com.lzy.model.AuthUser;
import com.lzy.properties.TokenProperties;
import com.lzy.token.factory.TokenFactoryService;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.Optional;

*/
/**
 * @author lzy by 2020/8/8 20:09
 *//*

@Component
public class JwtTokenFactoryServiceImpl implements TokenFactoryService {

    private TokenProperties tokenProperties;

    @Override
    public AuthToken createAuthToken(AuthUser user) {
        String accessToken = TokenUtil.createAuthToken(tokenProperties.getSecret(), user, tokenProperties.getAccessTokenExpireTime());
        AuthToken token = new AuthToken();
        token.setAccessToken(accessToken);
        token.setAccessTokenExpiresIn(tokenProperties.getAccessTokenExpireTime());
        token.setCreateTime(System.currentTimeMillis());
        return token;
    }

    @Override
    public AuthUser getTokenData(String token) {
        try {
            Object o = TokenUtil.tokenAuthentication(token, tokenProperties.getSecret());
            Map<String, Object> map = Optional.ofNullable(o).map(o1 -> (Map<String, Object>) o).orElse(null);
            AuthUser authUser = new AuthUser();
            authUser.setId(Optional.of(map.get("id")).map(o1 -> Long.valueOf(o1.toString())).get());
            authUser.setCode(map.get("code").toString());
            authUser.setMemberCode(map.get("memberCode").toString());
            return authUser;
        } catch (Exception e) {
            return null;
        }
    }

    @Override
    public Boolean tokenAuthentication(String token) {
        try {
            TokenUtil.tokenAuthentication(token, tokenProperties.getSecret());
            return Boolean.TRUE;
        } catch (Exception e) {
            return Boolean.FALSE;
        }
    }


    public JwtTokenFactoryServiceImpl(TokenProperties tokenProperties) {
        this.tokenProperties = tokenProperties;
    }
}
*/
